package org.jeecg.modules.htxincailiao.order.domain.bo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.modules.htxincailiao.order.constant.HTOrderInfoTypeEnum;
import org.jeecg.modules.htxincailiao.order.constant.HTOrderTypeEnum;
import org.jeecgframework.poi.excel.annotation.Excel;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;

@Data
public class HTIndustryOrderCreateBO {

    /**
     * 报名对象：0-展商 1-观众
     */
    @Excel(name = "报名对象：0-展商 1-观众", width = 15, dicCode = "industry_meeting_apply_object_type")
    @Dict(dicCode = "industry_meeting_apply_object_type")
    @ApiModelProperty(value = "报名对象：0-展商 1-观众")
    @NotNull(message = "报名对象不能为空")
    private Integer applyObjectType;


    @NotNull(message = "订单类型不能为空")
    private HTOrderTypeEnum orderType;

    /**
     * 用户ID
     */
    @NotNull(message = "用户ID不能为空")
    private String buyerId;

    private String addressId;

    /**
     * 确定订单类型 0-微信支付 1-支付宝支付
     */
    @NotNull(message = "支付类型不能为空")
    private Integer paymentType=0;

    /**
     * 产品名称
     */
    @NotNull(message = "名称不能为空")
    private String name;


    /**
     * 会议ID
     */
    private String meetingId;

    /**
     * 展会ID
     */
    private String exhibitionId;

    /**
     * 沙龙ID
     */
    private String salonId;

    /**
     * 报名联系人
     */
    @Excel(name = "报名联系人", width = 15)
    @ApiModelProperty(value = "报名联系人")
    @NotNull(message = "联系人不能为空")
    private String contactPerson;

    /**
     * 报名联系人电话
     */
    @Excel(name = "报名联系人电话", width = 15)
    @ApiModelProperty(value = "联系手机号")
    @NotNull(message = "联系手机号不能为空")
    @Length(min = 11, max = 11, message = "手机号格式不正确")
    private String contactPhoneNumber;

    /**
     * 展商参展费
     */
    @Excel(name = "展商参展费", width = 15)
    @ApiModelProperty(value = "展商参展费")
    private BigDecimal exhibitorCost;
    /**
     * 观众观展费
     */
    @Excel(name = "观众观展费", width = 15)
    @ApiModelProperty(value = "观众观展费")
    private BigDecimal audienceCost;

    /**
     * 报名费（单票价格）
     */
    @Excel(name = "报名费（单票价格）", width = 15)
    @ApiModelProperty(value = "报名费（单票价格）")
    private BigDecimal applyCost;
    /**
     * 购买商品数量 - Type Integer
     */
    private Integer quantity;
    /**
     * 购买商品数量 - Type String
     */
    @NotNull(message = "购买商品数量不能为空")
    @Pattern(regexp = "^[1-9]\\d*$", message = "请输入大于0的数字")
    private String quantityString;
    /**
     * 确定订单类型 0-直接购买 1-购物车
     */
    @NotNull(message = "订单确认类型不能为空")
    private HTOrderInfoTypeEnum orderInfoType;
    private BigDecimal totalAmount;

    public BigDecimal getApplyCost() {
        if (this.applyObjectType == 0) {
            return exhibitorCost;
        } else if (this.applyObjectType == 1) {
            return audienceCost;
        } else {
            return new BigDecimal(0);
        }
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
        this.quantityString = quantity.toString();
    }

    public String getQuantityString() {
        return quantity.toString();
    }
}
